<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
            <title>
            </title>
            <link href="__LAYUI__/css/layui.css" rel="stylesheet" type="text/css"/>
            <script src="__LAYUI__/layui.js" type="text/javascript">
            </script>
            <script src="__STATIC__/js/form.js" type="text/javascript">
            </script>
        </meta>
    </head>
    <body>
        <form class="layui-form" name="adminForm" style="margin: 20px 50px;">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    角色
                </label>
                <div class="layui-input-inline">
                    <select lay-verify="required" name="role_id">
                        {volist name="roles" id="role"}
                        <option value="{$role.id}">{$role.title}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    帐号
                </label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="phone" name="mobile" placeholder="请填写是手机号" type="text">
                    </input>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    昵称
                </label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="required" name="nickname" type="text">
                    </input>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    密码
                </label>
                <div class="layui-input-inline">
                    <input class="layui-input" name="pass" placeholder="不修改请留空" type="password">
                    </input>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label width-small">
                    状态
                </label>
                <div class="layui-input-block">
                    <input checked="" name="status" title="正常" type="radio" value="1">
                        <input name="status" title="禁用" type="radio" value="0">
                        </input>
                    </input>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input name="id" style="display: none;" type="text" value="">
                        <button class="layui-btn layui-btn-normal" lay-filter="admin" lay-submit="">
                            提交
                        </button>
                    </input>
                </div>
            </div>
        </form>
        <script type="text/javascript">
            var formObj = new Form('adminForm');
      formObj.init({$admin});

      layui.use(['form','layer'], function(){
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form();

        form.on('submit(admin)', function(e){
          $.post("{:url('admin/Admin/admin')}", e.field, function(res){
            if(res.status == 1){
              layer.msg(res.msg,{time:1000},function(){
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
                parent.location.reload();
              });
            }else{
              layer.msg(res.msg);
            }
          },'json');
          return false;
        });

      });
        </script>
    </body>
</html>
